Php/zend framework/zend queue/dbモデル
提供: 初心者エンジニアの簡易メモ
-batch/sample.php
require_once APPLICATION_PATH . '/models/que/TestsQue.php'; $que = new TestsQue(); $messages = $que->receive(5); foreach ($messages as $i => $message) { echo $message->body, "\n"; $que->deleteMessage($message); } $que->send("My Test Message");
-models/que/AbstractQue.php
abstract class AbstractQue extends Zend_Queue { protected $_name = ""; public function __construct() { if (!$this->_name) return; $config = ConfigModel::getInstance(APPLICATION_PATH . '/configs/db.ini', APPLICATION_ENV); $driverOptions = $config->default->params->toArray(); $driverOptions['type'] = $config->default->adapter; $options = array( 'driverOptions' => $driverOptions, 'options' => array( Zend_Db_Select::FOR_UPDATE => true ), 'name' => $this->_name, ); parent::__construct('Db', $options); } public function count() { return count($this); } }
-models/que/TestsQue.php
require_once __DIR__ . '/AbstractQue.php'; class TestsQue extends AbstractQue { protected $_name = "queue1"; }